package elitech.vietnam.myfashion.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import elitech.vietnam.myfashion.MainActivity;
import elitech.vietnam.myfashion.gcm.GCMIntentService;
import elitech.vietnam.myfashion.view.FollowListView;

public class FollowListFragment extends Fragment {

	private MainActivity mContext;
	public FollowListView mView = null;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.mContext = (MainActivity) getActivity();
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		if (!mContext.mMainPageViewFragment.isHidden()) {
			mContext.AddPreferenceInt("FirstStart", 0);
			Intent intent = new Intent(mContext, MainActivity.class);
			if(mContext.getIntent().getExtras()!=null){
			String notiExtras = mContext.getIntent().getExtras().getString(GCMIntentService.DATA_TAG);
			if (notiExtras != null && !notiExtras.equals(""))
				intent.putExtra(GCMIntentService.DATA_TAG, notiExtras);
			}
			mContext.startActivity(intent);
			mContext.finish();
		} else
			mView = new FollowListView(mContext);
		return mView;
	}
	
	@Override
	public void onResume() {
		super.onResume();
		int tab = (getArguments() != null) ? getArguments().getInt("TAB") : 0;
		if (tab > 0)
			mView.ChangeTab(tab);
	}

	@Override
	public void onDestroy() {
		mContext.mProductCategory = null;
		super.onDestroy();
	}
}
